#include "stdafx.h"
#include "BaseBullet.h"


CBaseBullet::CBaseBullet()
{
	
}


CBaseBullet::~CBaseBullet()
{
}

void CBaseBullet::InitDirFaceImg()
{
	m_DirFaceImg = cvCreateImage(CvSize(m_FaceImg->width, m_FaceImg->height), m_FaceImg->depth, m_FaceImg->nChannels);
}

void CBaseBullet::Move()
{
	double angle = Tool->GainAngle(m_Object->GetMapPos(), m_Pos);
	angle = fabs(angle);
	angle = angle > 90 ? 180 - angle : angle;
	if (m_Object->GetMapPos().x > m_Pos.x)
	{
		if (m_Object->GetMapPos().y > m_Pos.y)
		{
			m_Pos.x += BULLET_SPEED*cos(angle);
			m_Pos.y += BULLET_SPEED*sin(angle);
		}
		else
		{
			m_Pos.x += BULLET_SPEED*cos(angle);
			m_Pos.y -= BULLET_SPEED*sin(angle);
		}
	}
	else
	{
		if (m_Object->GetMapPos().y > m_Pos.y)
		{
			m_Pos.x -= BULLET_SPEED*cos(angle);
			m_Pos.y += BULLET_SPEED*sin(angle);
		}
		else
		{
			m_Pos.x -= BULLET_SPEED*cos(angle);
			m_Pos.y -= BULLET_SPEED*sin(angle);
		}
	}
}

void CBaseBullet::Draw()
{

}

void CBaseBullet::SetTool(CTool * tool)
{
	Tool = tool;
}

void CBaseBullet::SetPos(CvPoint pos)
{
	m_Pos = pos;
}

void CBaseBullet::SetATK(int atk)
{
	m_ATK = atk;
}

void CBaseBullet::SetObject(CBaseMonster * object)
{
	m_Object = object;
}

void CBaseBullet::SetFaceImg(IplImage *face)
{
	m_FaceImg = face;
}
